package bizlogic;

import java.util.ArrayList;

import model.FacilityDTO;
import model.FacilitySearchDTO;
import model.FacilityDTO;
import model.FacilitySearchDTO;
import model.FacilityDTO;

import dao.DAOException;
import dao.DAOFactory;
import dao.FacilityDAO;
import dao.mysql.FacilityDAOImpl;

public class FacilityManager {
    
	private FacilityDAO facilityDAO;
	
	public FacilityManager() 
	{
		facilityDAO= DAOFactory.loadInstance().getFacilityDAO();
	}
	
	@SuppressWarnings("finally")
	public ArrayList<FacilityDTO> findHerosByCriteria(FacilitySearchDTO fso)
	{
		ArrayList<FacilityDTO> currentList = new ArrayList<FacilityDTO>();
		try {
			currentList = facilityDAO.findFacilityByCriteria(fso);
		} catch (DAOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} finally
		{
			return currentList;
		}
		
	}
	@SuppressWarnings("finally")
	public FacilityDTO getFacility(String name){
		FacilityDTO currentFacility = null;
		try {
			currentFacility = facilityDAO.getFacility(name);
		} catch (DAOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} finally
		{
			return currentFacility;
		}
		
	}
	 @SuppressWarnings("finally")
		public ArrayList<FacilityDTO> getAll() {
	    	ArrayList<FacilityDTO> currentFacilityList = new ArrayList<FacilityDTO>();
			try {
				currentFacilityList = facilityDAO.getAll();
			} catch (DAOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			} finally
			{
				return currentFacilityList;
			}
	    }
	 public void insertFacility(FacilityDTO facility) {
	    	try {
				facilityDAO.insertFacility(facility);
			} catch (DAOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
	    }
	 public void updateFacility(FacilityDTO facility) {
	    	try {
				facilityDAO.updateFacility(facility);
			} catch (DAOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
	    }
	 public void deleteFacility(FacilityDTO facility) {
	    	try {
	    		facilityDAO.deleteFacility(facility);
			} catch (DAOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
	    }
}
